home *** CD-ROM | disk | FTP | other *** search
- These are my patches to Berkeley bind version 4.8.1.
- Unshar, then apply all the patch files in the order implied by their
- names.
-
- USE AT YOUR OWN RISK.
-
- --apb
- Alan Barrett, Dept. of Electronic Eng., Univ. of Natal, Durban, South Africa
- RFC822: barrett@ee.und.ac.za Bang: m2xenix!quagga!undeed!barrett
-
- ------
- # This is a shell archive. Remove anything before this line,
- # then unpack it by saving it in a file and typing "sh file".
- #
- # Wrapped by Alan P Barrett <barrett@undeed> on Sun Aug 11 18:28:03 1991
- #
- # This archive contains:
- # apb-901127 apb-910129 apb-910130
- #
-
- LANG=""; export LANG
- PATH=/bin:/usr/bin:$PATH; export PATH
-
- echo x - apb-901127
- sed 's/^@//' >apb-901127 <<'@EOF'
- Index: Makefile
- *** old/Makefile Wed Dec 5 09:41:53 1990
- --- apb-901127/Makefile Wed Dec 5 09:41:58 1990
- @@@ -16,23 +16,48 @@
- #
- # @(#)Makefile 4.19 (Berkeley) 2/8/89
- #
- -DEFINES= -DDEBUG -DSTATS
- +
- +# Put some of the following symbols into SYSDEFINES. (The SYSV symbol
- +# used to control all this.)
- +#
- +# HAVE_GETDTABLESIZE # getdtablesize() is available (BSD)
- +# HAVE_SIGVEC # sigvec() and other BSD signal stuff is available (BSD)
- +# HAVE_SETLINEBUF # setlinebuf() is available (BSD)
- +# HAVE_UTIMES # utimes() is available (BSD)
- +# HAVE_MKSTEMP # mkstemp() is available (BSD)
- +# HAVE_STRCASECMP # strcasecmp() and strncasecmp() are available (BSD)
- +# HAVE_WAIT3 # wait3() is available (BSD)
- +# NEED_FCNTL_H # fcntl.h must be included (SYSV)
- +# NEED_UNISTD_H # unistd.h must be included (SYSV)
- +#
- +# pure BSD
- +#SYSDEFINES= -DHAVE_GETDTABLESIZE -DHAVE_SIGVEC -DHAVE_SETLINEBUF \
- +# -DHAVE_UTIMES -DHAVE_MKSTEMP -DHAVE_STRCASECMP -DHAVE_WAIT3
- +# pure SYSV
- +#SYSDEFINES= -DNEED_FCNTL_H -DNEED_UNISTD_H
- +#
- +# HP-UX 7.0
- +SYSDEFINES= -DHAVE_SIGVEC -DHAVE_WAIT3 -DNEED_FCNTL_H -DNEED_UNISTD_H
- +
- +DEFINES= ${SYSDEFINES} -DDEBUG -DSTATS
- ### -DALLOW_T_UNSPEC -Dmalloc=rt_malloc -Dfree=rt_free
- ### ALLOC=storage.o
- -CFLAGS= -O ${DEFINES}
- +DEBUG= -g
- +OPTIMISE= # -O
- +CFLAGS= ${OPTIMISE} ${DEBUG} ${DEFINES}
-
- RES=
- -LIBS= ${RES}
- +LIBS= -lBSD ${RES}
- LIBC= /lib/libc.a
-
- SRCS= db_dump.c db_load.c db_lookup.c db_reload.c db_save.c db_update.c \
- ns_forw.c ns_init.c ns_main.c ns_maint.c ns_req.c ns_resp.c \
- - ns_sort.c ns_stats.c db_glue.c xfer.c
- + ns_sort.c ns_stats.c db_glue.c xfer.c misc.c
- HDRS= db.h ns.h
- OBJS= db_dump.o db_load.o db_lookup.o db_reload.o db_save.o db_update.o \
- ns_forw.o ns_init.o ns_main.o ns_maint.o ns_req.o ns_resp.o \
- - ns_sort.o ns_stats.o db_glue.o $(ALLOC)
- -XFEROBJ= xfer.o db_glue.o
- + ns_sort.o ns_stats.o db_glue.o misc.o $(ALLOC)
- +XFEROBJ= xfer.o db_glue.o misc.o
-
- SUBDIR= tools
- MAN= named.0
- @@@ -43,10 +68,10 @@
-
- named: ${OBJS} ${LIBC}
- sh newvers.sh
- - ${CC} -o $@ version.c ${OBJS} ${LIBS}
- + ${CC} ${DEBUG} -o $@ version.c ${OBJS} ${LIBS}
-
- xfer: ${XFEROBJ} ${LIBC}
- - ${CC} -o $@ ${XFEROBJ} ${LIBS}
- + ${CC} ${DEBUG} -o $@ ${XFEROBJ} ${LIBS}
-
- clean:
- rm -f ${OBJS} ${XFEROBJ} core named xfer version.o version.c
-
- Index: db_load.c
- *** old/db_load.c Wed Dec 5 09:41:56 1990
- --- apb-901127/db_load.c Wed Dec 5 09:42:03 1990
- @@@ -98,9 +98,10 @@
- * Load the database from 'filename'. Origin is appended to all domain
- * names in the file.
- */
- -db_load(filename, in_origin, zp)
- +db_load(filename, in_origin, zp, including)
- char *filename, *in_origin;
- struct zoneinfo *zp;
- + int including;
- {
- register u_char *cp;
- register struct map *mp;
- @@@ -115,14 +116,15 @@
- int read_soa = 0; /* number of soa's read */
- struct databuf *dp;
- FILE *fp;
- - int slineno, i, errs = 0, didinclude = 0;
- + int slineno, i, errs = 0;
- register u_long n;
- struct stat sb;
-
- #ifdef DEBUG
- if (debug)
- - fprintf(ddt,"db_load(%s, %s, %d)\n",
- - filename, in_origin, zp - zones);
- + fprintf(ddt,"db_load(%s, %s, %d)%s\n",
- + filename, in_origin, zp - zones,
- + (including ? " include" : ""));
- #endif
-
- (void) strcpy(origin, in_origin);
- @@@ -151,7 +153,9 @@
- lineno = 1;
- domain[0] = '\0';
- class = C_IN;
- - zp->z_state &= ~Z_INCLUDE;
- + if (!including) {
- + zp->z_state &= ~Z_INCLUDE;
- + }
- while ((c = gettoken(fp)) != EOF) {
- switch (c) {
- case INCLUDE:
- @@@ -163,9 +167,8 @@
- makename(tmporigin, origin);
- endline(fp);
- }
- - didinclude = 1;
- zp->z_state |= Z_INCLUDE;
- - errs += db_load(buf, tmporigin, zp);
- + errs += db_load(buf, tmporigin, zp, 1);
- continue;
-
- case ORIGIN:
- @@@ -485,18 +488,22 @@
- lineno++;
- }
- (void) fclose(fp);
- - if (didinclude)
- + if (zp->z_state & Z_INCLUDE)
- zp->z_ftime = 0;
- else
- zp->z_ftime = sb.st_mtime;
- zp->z_lastupdate = sb.st_mtime;
- lineno = slineno;
- - if (zp->z_type != Z_CACHE && read_soa != 1) {
- + if (zp->z_type != Z_CACHE && !including && read_soa != 1) {
- errs++;
- if (read_soa == 0)
- syslog(LOG_ERR, "%s: no SOA record", filename);
- else
- syslog(LOG_ERR, "%s: multiple SOA records", filename);
- + }
- + else if (zp->z_type != Z_CACHE && including && read_soa != 0) {
- + errs++;
- + syslog(LOG_ERR, "%s: SOA found in include file", filename);
- }
- return (errs);
- }
-
- ##### old/misc.c does not exist.
- Index: misc.c
- *** /dev/null Wed Dec 5 09:43:06 1990
- --- apb-901127/misc.c Wed Dec 5 09:42:13 1990
- @@@ -1,0 +1,51 @@
- +/* assorted stuff presumably found in BSD libraries? --apb */
- +
- +#if defined(NEED_FCNTL_H)
- +#include <fcntl.h>
- +#endif
- +
- +#if !defined(HAVE_MKSTEMP)
- +int
- +mkstemp (template)
- + char *template;
- +{
- + extern char *mktemp();
- + char *name = mktemp (template);
- +
- + /* return 0 if failed to make name.
- + This is silly, becase 0 is also a valid fd, but that is what
- + xfer.c tests for. */
- +
- + if (*name == '\0') return 0;
- + return open (name, O_RDWR|O_CREAT, 0644);
- +}
- +#endif
- +
- +#if !(definedHAVE_STRCASECMP)
- +int
- +strcasecmp (s1, s2)
- + char *s1, *s2;
- +{
- + while (*s1 != '\0' && *s2 != '\0' && tolower(*s1) == tolower(*s2)) {
- + s1++;
- + s2++;
- + }
- + return (tolower(*s2) - tolower(*s1));
- +}
- +
- +int
- +strncasecmp (s1, s2, n)
- + char *s1, *s2;
- + int n;
- +{
- + while (n > 0 &&
- + *s1 != '\0' && *s2 != '\0' && tolower(*s1) == tolower(*s2))
- + {
- + n--;
- + s1++;
- + s2++;
- + }
- + if (n == 0) return 0;
- + else return (tolower(*s2) - tolower(*s1));
- +}
- +#endif
-
- Index: ns_init.c
- *** old/ns_init.c Wed Dec 5 09:42:05 1990
- --- apb-901127/ns_init.c Wed Dec 5 09:42:10 1990
- @@@ -239,7 +239,7 @@
- if (debug)
- fprintf(ddt, "reloading zone\n");
- #endif
- - (void) db_load(zp->z_source, zp->z_origin, zp);
- + (void) db_load(zp->z_source, zp->z_origin, zp, 0);
- break;
-
- case Z_PRIMARY:
- @@@ -274,7 +274,7 @@
- if (debug)
- fprintf(ddt, "reloading zone\n");
- #endif
- - if (db_load(zp->z_source, zp->z_origin, zp) == 0)
- + if (db_load(zp->z_source, zp->z_origin, zp, 0) == 0)
- zp->z_auth = 1;
- #ifdef ALLOW_UPDATES
- /* Guarantee calls to ns_maint() */
- @@@ -416,7 +416,7 @@
- * immediately.
- */
- if (zp->z_source == NULL ||
- - db_load(zp->z_source, zp->z_origin, zp) != 0) {
- + db_load(zp->z_source, zp->z_origin, zp, 0) != 0) {
- /*
- * Set zone to be refreshed immediately.
- */
-
- Index: ns_main.c
- *** old/ns_main.c Wed Dec 5 09:42:06 1990
- --- apb-901127/ns_main.c Wed Dec 5 09:42:10 1990
- @@@ -30,12 +30,14 @@
- */
-
- #include <sys/param.h>
- -#if defined(SYSV)
- +/* #if defined(SYSV) */
- +#if defined(NEED_FCNTL_H)
- #include <fcntl.h>
- #endif SYSV
- #include <sys/file.h>
- #include <sys/time.h>
- -#if !defined(SYSV)
- +/* #if !defined(SYSV) */
- +#if defined(HAVE_WAIT3)
- #include <sys/wait.h>
- #endif !SYSV
- #include <sys/resource.h>
- @@@ -132,7 +134,8 @@
-
- extern int errno;
-
- -#if defined(SYSV)
- +/* #if defined(SYSV) */
- +#if !defined(HAVE_GETDTABLESIZE)
- getdtablesize()
- {
- return(FD_SETSIZE);
- @@@ -153,7 +156,8 @@
- u_long lasttime, maxctime;
- u_long nnn, nm;
- char buf[BUFSIZ];
- -#ifndef SYSV
- +/* #ifndef SYSV */
- +#ifdef HAVE_SIGVEC
- struct sigvec vec;
- #endif
-
- @@@ -271,7 +275,8 @@
- resettime = boottime;
-
- (void) signal(SIGHUP, onhup);
- -#if defined(SYSV)
- +/* #ifndef SYSV */
- +#if defined(HAVE_SIGVEC)
- (void) signal(SIGCLD, endxfer);
- (void) signal(SIGALRM, maint_alarm);
- #else
- @@@ -283,7 +288,7 @@
- vec.sv_handler = endxfer;
- vec.sv_mask = sigmask(SIGALRM);
- (void) sigvec(SIGCHLD, &vec, (struct sigvec *)NULL);
- -#endif SYSV
- +#endif HAVE_SIGVEC
- (void) signal(SIGPIPE, SIG_IGN);
- (void) signal(SIGSYS, sigprof);
- (void) signal(SIGINT, setdumpflg);
- @@@ -537,7 +542,11 @@
- (void)setsockopt(dqp->dq_dfd, SOL_SOCKET, SO_RCVBUF,
- (char *)&rbufsize, sizeof(rbufsize));
- #endif SO_RCVBUF
- +#ifdef O_NONBLOCK
- + (void) fcntl(dqp->dq_dfd, F_SETFL, O_NONBLOCK);
- +#else
- (void) fcntl(dqp->dq_dfd, F_SETFL, FNDELAY);
- +#endif
- /*
- * NOTE: Some versions of SunOS have problems with the following
- * call to bind. Bind still seems to function on these systems
- @@@ -573,7 +582,8 @@
- (void) close(n);
- n = open("/dev/tty", O_RDWR);
- if (n > 0) {
- -#ifndef SYSV
- +/* #ifndef SYSV */
- +#ifdef TIOCNOTTY
- (void) ioctl(n, TIOCNOTTY, (char *)NULL);
- #else
- setpgrp();
- @@@ -659,7 +669,7 @@
- if (retryqp != NULL) {
- gettime(&tt);
- t.tv_sec = (long) retryqp->q_time - tt.tv_sec;
- - if (t.tv_sec <= 0) {
- + if ((int) t.tv_sec <= 0) {
- retry(retryqp);
- continue;
- }
- @@@ -689,11 +699,15 @@
- if ((n = recvfrom(dqp->dq_dfd, buf, sizeof(buf), 0,
- (struct sockaddr *)&from_addr, &from_len)) < 0)
- {
- - if ((n == -1) && (errno == EWOULDBLOCK))
- + if ((n == -1) &&
- + (errno == EWOULDBLOCK || errno == EAGAIN))
- break;
- syslog(LOG_WARNING, "recvfrom: %m");
- break;
- }
- + if (n == 0) {
- + break;
- + }
- #ifdef STATS
- stats[S_INPKTS].cnt++;
- #endif
- @@@ -722,6 +736,9 @@
- rfd = accept(vs, (struct sockaddr *)&from_addr, &from_len);
- gettime(&tt);
- if (rfd < 0 && errno == EMFILE && streamq != NULL) {
- + /* Out of file descriptors. Close all streams
- + that have been idle for 15 minutes. Also
- + determine which has been idle longest. */
- maxctime = 0;
- candidate = QSTREAM_NULL;
- for (sp = streamq; sp != QSTREAM_NULL;
- @@@ -729,8 +746,15 @@
- if (sp->s_refcnt != 0)
- continue;
- lasttime = tt.tv_sec - sp->s_time;
- - if (lasttime >= 900)
- + if (lasttime >= 900) {
- +#ifdef DEBUG
- + if (debug > 6) {
- + fprintf (ddt,
- + "sp x%x inactive\n",sp);
- + }
- +#endif
- sqrm(sp, &mask);
- + }
- else if (lasttime > maxctime) {
- candidate = sp;
- maxctime = lasttime;
- @@@ -739,6 +763,14 @@
- rfd = accept(vs, (struct sockaddr *)&from_addr, &from_len);
- if ((rfd < 0) && (errno == EMFILE) &&
- candidate != QSTREAM_NULL) {
- + /* still out of file descriptors.
- + close the least active stream. */
- +#ifdef DEBUG
- + if (debug > 6) {
- + fprintf (ddt,
- + "sp x%x inactive\n",sp);
- + }
- +#endif
- sqrm(candidate, &mask);
- rfd = accept(vs, (struct sockaddr *)&from_addr, &from_len);
- }
- @@@ -747,7 +779,11 @@
- syslog(LOG_WARNING, "accept: %m");
- continue;
- }
- +#ifdef O_NONBLOCK
- + (void) fcntl(rfd, F_SETFL, O_NONBLOCK);
- +#else
- (void) fcntl(rfd, F_SETFL, FNDELAY);
- +#endif
- (void) setsockopt(rfd, SOL_SOCKET, SO_KEEPALIVE,
- (char *)&on, sizeof(on));
- if ((sp = sqadd()) == QSTREAM_NULL) {
- @@@ -800,9 +836,21 @@
- sp->s_bufp += n;
- size -= n;
- }
- - if ((n == -1) && (errno == EWOULDBLOCK))
- + if ((n == -1) &&
- + (errno == EWOULDBLOCK || errno == EAGAIN))
- continue;
- if (n <= 0) {
- +#ifdef DEBUG
- + if (n == 0 && debug > 6) {
- + fprintf (ddt,
- + "sp x%x eof\n",sp);
- + }
- + else if (n < 0 && debug > 5) {
- + fprintf (ddt,
- + "sp x%x read errno=%d\n",
- + sp,errno);
- + }
- +#endif
- sp->s_refcnt = 0;
- sqrm(sp, &mask);
- continue;
- @@@ -863,9 +911,21 @@
- sizeof(HEADER));
- continue;
- }
- - if ((n == -1) && (errno == EWOULDBLOCK))
- + if ((n == -1) &&
- + (errno == EWOULDBLOCK || errno == EAGAIN))
- continue;
- if (n <= 0) {
- +#ifdef DEBUG
- + if (n == 0 && debug > 6) {
- + fprintf (ddt,
- + "sp x%x eof\n",sp);
- + }
- + else if (n < 0 && debug > 5) {
- + fprintf (ddt,
- + "sp x%x read errno=%d\n",
- + sp,errno);
- + }
- +#endif
- sp->s_refcnt = 0;
- sqrm(sp, &mask);
- continue;
- @@@ -884,8 +944,7 @@
- continue;
- }
- }
- - }
- - }
- + } }
- /* NOTREACHED */
- }
-
- @@@ -903,7 +962,8 @@
-
- onhup()
- {
- -#if defined(SYSV)
- +/* #if defined(SYSV) */
- +#if !defined(HAVE_SIGVEC)
- (void)signal(SIGHUP, onhup);
- #endif SYSV
- needreload = 1;
- @@@ -917,7 +977,8 @@
-
- maint_alarm()
- {
- -#if defined(SYSV)
- +/* #if defined(SYSV) */
- +#if !defined(HAVE_SIGVEC)
- (void)signal(SIGALRM, maint_alarm);
- #endif SYSV
- needmaint = 1;
- @@@ -943,7 +1004,8 @@
- */
- int setdumpflg()
- {
- -#if defined(SYSV)
- +/* #if defined(SYSV) */
- +#if !defined (HAVE_SIGVEC)
- (void)signal(SIGINT, setdumpflg);
- #endif SYSV
- needToDoadump = 1;
- @@@ -978,7 +1040,8 @@
- if ( ddt == NULL)
- syslog(LOG_WARNING, "can't open debug file: %m");
- else {
- -#if defined(SYSV)
- +/* #if defined(SYSV) */
- +#ifndef HAVE_SETLINEBUF
- setvbuf(ddt, NULL, _IOLBF, BUFSIZ);
- #else
- setlinebuf(ddt);
- @@@ -1006,7 +1069,8 @@
-
- setIncrDbgFlg()
- {
- -#if defined(SYSV)
- +/* #if defined(SYSV) */
- +#if !defined (HAVE_SIGVEC)
- (void)signal(SIGUSR1, setIncrDbgFlg);
- #endif SYSV
- #ifdef DEBUG
- @@@ -1027,7 +1091,8 @@
-
- setNoDbgFlg()
- {
- -#if defined(SYSV)
- +/* #if defined(SYSV) */
- +#if !defined (HAVE_SIGVEC)
- (void)signal(SIGUSR2, setNoDbgFlg);
- #endif SYSV
- setdebug(0);
- @@@ -1038,7 +1103,8 @@
- */
- setstatsflg()
- {
- -#if defined(SYSV)
- +/* #if defined(SYSV) */
- +#if !defined (HAVE_SIGVEC)
- (void)signal(SIGIOT, setstatsflg);
- #endif SYSV
- needStatsDump = 1;
- @@@ -1046,7 +1112,8 @@
-
- int setchkptflg()
- {
- -#if defined(SYSV)
- +/* #if defined(SYSV) */
- +#if !defined (HAVE_SIGVEC)
- (void)signal(SIGQUIT, setchkptflg);
- #endif SYSV
- needToChkpt = 1;
- @@@ -1061,7 +1128,8 @@
-
- sigprof()
- {
- -#if defined(SYSV)
- +/* #if defined(SYSV) */
- +#if !defined (HAVE_SIGVEC)
- (void)signal(SIGSYS, sigprof);
- #endif SYSV
- #ifdef DEBUG
-
- Index: ns_maint.c
- *** old/ns_maint.c Wed Dec 5 09:42:07 1990
- --- apb-901127/ns_maint.c Wed Dec 5 09:42:11 1990
- @@@ -22,7 +22,8 @@
- #include <sys/param.h>
- #include <sys/socket.h>
- #include <sys/time.h>
- -#if defined(SYSV)
- +/* #if defined(SYSV) */
- +#if defined (NEED_UNISTD_H)
- #include <unistd.h>
- #endif SYSV
- #include <netinet/in.h>
- @@@ -200,7 +201,8 @@
- #endif /* ECHOARGS */
- #endif /* DEBUG */
-
- -#ifdef SYSV
- +/* #ifdef SYSV */
- +#if !defined(HAVE_SIGVEC)
- #define vfork fork
- #else
- omask = sigblock(sigmask(SIGCHLD));
- @@@ -211,7 +213,8 @@
- fprintf(ddt, "xfer [v]fork: %d\n", errno);
- #endif
- syslog(LOG_ERR, "xfer [v]fork: %m");
- -#ifndef SYSV
- +/* #ifndef SYSV */
- +#if defined(HAVE_SIGVEC)
- (void) sigsetmask(omask);
- #endif
- zp->z_time = tt.tv_sec + 10;
- @@@ -228,7 +231,8 @@
- zp->z_xferpid = pid;
- xfers_running++;
- zp->z_time = tt.tv_sec + MAX_XFER_TIME;
- -#ifndef SYSV
- +/* #ifndef SYSV */
- +#if defined(HAVE_SIGVEC)
- (void) sigsetmask(omask);
- #endif
- } else {
- @@@ -393,7 +397,8 @@
- zp->z_time = tt.tv_sec + zp->z_retry;
- }
-
- -#ifdef SYSV
- +/* #ifdef SYSV */
- +#ifndef HAVE_WAIT3
- union wait {
- unsigned short w_termsig:7; /* termination signal */
- unsigned short w_coredump:1; /* core dump indicator */
- @@@ -411,13 +416,16 @@
- union wait status;
-
- gettime(&tt);
- -#if defined(SYSV)
- +/* #if defined(SYSV) */
- +#if !defined(HAVE_WAIT3)
- { int stat;
- pid = wait(&stat);
- status.w_termsig = stat & 0x7f;
- status.w_retcode = stat >> 8;
- }
- +#if !defined(HAVE_SIGVEC)
- (void)signal(SIGCLD, endxfer);
- +#endif
- #ifdef DEBUG
- if (debug > 1)
- fprintf(ddt, "child %d returned status=%d\n", pid, status);
- @@@ -453,7 +461,8 @@
- zp->z_lastupdate = tt.tv_sec;
- zp->z_time = tt.tv_sec + zp->z_refresh;
- if (zp->z_source) {
- -#if defined(SYSV)
- +/* #if defined(SYSV) */
- +#ifndef HAVE_UTIMES
- struct utimbuf t;
-
- t.actime = tt.tv_sec;
- @@@ -505,7 +514,8 @@
- }
- break;
- }
- -#ifndef SYSV
- +/* #ifndef SYSV */
- +#if defined(HAVE_WAIT3)
- }
- #endif /* SYSV */
- for (zp = zones;
- @@@ -530,7 +540,7 @@
- zp->z_state &= ~Z_NEED_RELOAD;
- zp->z_auth = 0;
- remove_zone(hashtab, zp - zones);
- - if (db_load(zp->z_source, zp->z_origin, zp) == 0)
- + if (db_load(zp->z_source, zp->z_origin, zp, 0) == 0)
- zp->z_auth = 1;
-
- /*
-
- Index: ns_req.c
- *** old/ns_req.c Wed Dec 5 09:42:01 1990
- --- apb-901127/ns_req.c Wed Dec 5 09:42:06 1990
- @@@ -1026,13 +1026,38 @@
- }
-
- /* next do subdomains, unless delegated */
- - if ((isroot == 0 && fndns) || np->n_hash == NULL)
- - return;
- - npp = np->n_hash->h_tab;
- - nppend = npp + np->n_hash->h_size;
- +
- + if (isroot == 0 && fndns) {
- + return; /* subdomain is delegated */
- + }
- +
- + /* We find the subdomains by looking in the hash table for this
- + domain, but the root domain needs special treatment, because
- + the hash table pointed to by the global hashtab variable
- + contains entries for the root domain (.) and for all
- + top-level domains, while the root domain itself doesn't have
- + a hash table.
- +
- + If we are not dealing with the root domain then we just set
- + htp to point to the hash table for the current domain.
- +
- + If we are dealing with the root domain, then we set htp to
- + point to the global hash table, and take care not to
- + re-process the entry for the root domain when it is found in
- + the hash table.
- + */
- +
- + htp = ((dname[0] == '\0') ? hashtab : np->n_hash);
- + if (htp == NULL) {
- + return; /* no subdomains */
- + }
- + npp = htp->h_tab;
- + nppend = npp + htp->h_size;
- while (npp < nppend) {
- for (np = *npp++; np != NULL; np = np->n_next) {
- + if (np->n_dname[0] != '\0') { /* don't redo root domain */
- doaxfr(np, rfp, 0);
- + }
- }
- }
- #ifdef DEBUG
- @@@ -1284,6 +1309,7 @@
- if (debug >= 5)
- fprintf(ddt,"startxfr()\n");
- #endif
- +#ifndef NO_FORK_AXFR
- /*
- * child does the work while
- * the parent continues
- @@@ -1293,17 +1319,27 @@
- if (debug >= 5)
- fprintf(ddt,"startxfr: child pid %d\n", getpid());
- #endif
- +#endif /* NO_FORK_AXFR */
- rfp = fdopen(qsp->s_rfd, "w");
- +#ifndef NO_FORK_AXFR
- setproctitle("zone XFR to", qsp->s_rfd);
- +#endif /* NO_FORK_AXFR */
- fdstat = fcntl(qsp->s_rfd, F_GETFL, 0);
- if (fdstat != -1)
- +#ifdef O_NONBLOCK
- + (void) fcntl(qsp->s_rfd, F_SETFL,
- + fdstat & ~(FNDELAY | O_NONBLOCK));
- +#else
- (void) fcntl(qsp->s_rfd, F_SETFL, fdstat & ~FNDELAY);
- +#endif
- fwritemsg(rfp, msg, msglen);
- doaxfr(np, rfp, 1);
- fwritemsg(rfp, msg, msglen);
- (void) fflush(rfp);
- +#ifndef NO_FORK_AXFR
- exit(0);
- }
- +#endif /* NO_FORK_AXFR */
- qsp->s_time = tt.tv_sec;
- qsp->s_refcnt--;
- }
-
- Index: ns_resp.c
- *** old/ns_resp.c Wed Dec 5 09:42:08 1990
- --- apb-901127/ns_resp.c Wed Dec 5 09:42:12 1990
- @@@ -1360,6 +1360,9 @@
- register struct databuf **nspp;
- struct hashbuf *htp = hashtab;
-
- + *countp = 0;
- + nsp[0] = NULL;
- +
- if (priming && (np == NULL || np->n_dname[0] == '\0'))
- htp = fcachetab;
- try_again:
-
- @EOF
-
- chmod 644 apb-901127
-
- echo x - apb-910129
- sed 's/^@//' >apb-910129 <<'@EOF'
- Index: ns_init.c
- *** apb-901127/ns_init.c Tue Jan 29 15:47:12 1991
- --- apb-910129/ns_init.c Tue Jan 29 15:47:25 1991
- @@@ -311,10 +311,27 @@
- }
- } while (getword(buf, sizeof(buf), fp));
- #ifdef DEBUG
- - if (debug)
- - fprintf(ddt,"addrcnt = %d\n", zp->z_addrcnt);
- + if (debug) {
- + fprintf(ddt,"addrcnt = %d\n\tbackup file: %s\n",
- + zp->z_addrcnt, (source ? source : "(none)"));
- + }
- #endif
- +
- /*
- + * Transfers don't work without a backup file
- + * for secondary zones, because the named-xfer
- + * program insists on a file name.
- + *
- + * XXX perhaps we could allocate a temp file for
- + * this purpose?
- + */
- + if (! source) {
- + syslog(LOG_ERR,
- + "%s: line %d: no zone backup file\n",
- + bootfile, lineno);
- + }
- +
- + /*
- * If we had a backup file name, and it was changed,
- * free old zone and start over. If we don't have
- * current zone contents, try again now in case
- @@@ -503,6 +520,8 @@
- }
- #endif ALLOW_UPDATES
-
- +#if 0
- +/* xfer.c has its own soa_zinfo function, so this is unused. --apb */
- soa_zinfo(zp, cp, eom)
- register struct zoneinfo *zp;
- register u_char *cp;
- @@@ -520,6 +539,7 @@
- GETLONG(zp->z_expire, cp);
- GETLONG(zp->z_minimum, cp);
- }
- +#endif
-
- get_forwarders(fp)
- FILE *fp;
- @@@ -615,7 +635,7 @@
- int end;
- {
- int i;
- - for(i=1;i<=end;i++){
- + for(i=0;i<end;i++){
- printzoneinfo(i) ;
- }
- }
-
- Index: ns_maint.c
- *** apb-901127/ns_maint.c Tue Jan 29 15:47:13 1991
- --- apb-910129/ns_maint.c Tue Jan 29 15:47:28 1991
- @@@ -118,10 +118,28 @@
- /*
- * Find when the next refresh needs to be and set
- * interrupt time accordingly.
- + *
- + * Just looking at z_time is not enough, because when
- + * a zone transfer has just been started, z_time is set
- + * to (current time + MAX_REFRESH_TIME), which is when when
- + * a hung transfer needs to be aborted. If the transfer
- + * doesn't hang then endxfer() will set z_time to
- + * (time when transfer ends + z_refresh) or to (time when
- + * transfer ends + z_retry), and that might be a lot sooner
- + * than (current time + MAX_REFRESH_TIME).
- + *
- + * So, if a transfer is running, and (current time + z_retry)
- + * is sooner than the next maint interrupt would otherwise
- + * occur, we shedule the next maint interrupt for (current
- + * time + z_retry).
- */
- +
- if (next_refresh == 0 ||
- (zp->z_time != 0 && next_refresh > zp->z_time))
- next_refresh = zp->z_time;
- + if ((zp->z_state & Z_XFER_RUNNING) &&
- + (next_refresh > tt.tv_sec + zp->z_retry))
- + next_refresh = tt.tv_sec + zp->z_retry;
- }
-
- /*
- @@@ -130,7 +148,7 @@
- */
- bzero((char *)&ival, sizeof (ival));
- ival.it_value.tv_sec = next_refresh - tt.tv_sec;
- - if (ival.it_value.tv_sec < maint_interval)
- + if ((long) ival.it_value.tv_sec < maint_interval)
- ival.it_value.tv_sec = maint_interval;
- (void) setitimer(ITIMER_REAL, &ival, (struct itimerval *)NULL);
- #ifdef DEBUG
- @@@ -272,10 +290,12 @@
- fprintf(ddt,", expire = %ld", zp->z_expire);
- fprintf(ddt,", minimum = %ld", zp->z_minimum);
- fprintf(ddt,", serial = %ld\n", zp->z_serial);
- - fprintf(ddt,"z_time = %d", zp->z_time);
- - fprintf(ddt,", now time : %d sec", tt.tv_sec);
- - fprintf(ddt,", time left: %d sec; state %x\n", zp->z_time - tt.tv_sec,
- - zp->z_state);
- + fprintf(ddt,"lastupdate = %ld", (long) zp->z_lastupdate);
- + fprintf(ddt,", z_time = %ld", (long) zp->z_time);
- + fprintf(ddt,", now: %ld", (long) tt.tv_sec);
- + fprintf(ddt,", time left: %ld sec",
- + (long) zp->z_time - (long) tt.tv_sec);
- + fprintf(ddt,"; state %x\n", zp->z_state);
- }
- #endif DEBUG
-
-
- @EOF
-
- chmod 644 apb-910129
-
- echo x - apb-910130
- sed 's/^@//' >apb-910130 <<'@EOF'
- Index: ns_init.c
- *** apb-910129/ns_init.c Wed Jan 30 17:12:50 1991
- --- apb-910130/ns_init.c Wed Jan 30 17:18:12 1991
- @@@ -186,12 +186,9 @@
- zp->z_origin = savestr(obuf);
- zp->z_type = type;
- }
- - zp->z_addrcnt = 0;
- - zp->z_refresh = 0; /* by default, no dumping */
-
- switch (type) {
- case Z_CACHE:
- source = savestr(buf);
- + zp->z_refresh = 0; /* by default, no dumping */
- #ifdef DEBUG
- if (debug)
- fprintf(ddt,", source = %s\n", source);
- @@@ -283,6 +282,7 @@
- break;
-
- case Z_SECONDARY:
- + zp->z_addrcnt = 0;
- source = 0;
- #ifdef DEBUG
- if (debug)
- @@@ -332,28 +332,30 @@
- }
-
- /*
- - * If we had a backup file name, and it was changed,
- - * free old zone and start over. If we don't have
- - * current zone contents, try again now in case
- - * we have a new server on the list.
- + * If we've loaded this file, and the file has
- + * not been modified then there's no need to reload.
- */
- - if (zp->z_source &&
- - (source == 0 || strcmp(source, zp->z_source))) {
- + if (zp->z_source && source &&
- + strcmp(source, zp->z_source) == 0 &&
- + stat(zp->z_source, &f_time) == 0 &&
- + zp->z_ftime == f_time.st_mtime) {
- #ifdef DEBUG
- if (debug)
- - fprintf(ddt,"backup file changed\n");
- + fprintf(ddt, "zone is up to date\n");
- #endif
- + break; /* zone is already up to date */
- + }
- + if (zp->z_source) {
- free(zp->z_source);
- - zp->z_source = 0;
- - zp->z_auth = 0;
- - remove_zone(hashtab, zp - zones);
- + remove_zone(hashtab, zp - zones);
- }
- - if (zp->z_source)
- - free(source);
- - else
- - zp->z_source = source;
- - if (zp->z_auth == 0)
- - zoneinit(zp);
- + zp->z_source = source;
- + zp->z_auth = 0;
- +#ifdef DEBUG
- + if (debug)
- + fprintf(ddt, "reloading zone\n");
- +#endif
- + zoneinit(zp);
- break;
-
- }
-
- @EOF
-
- chmod 644 apb-910130
-
- exit 0
-